package game.controller.load{
	
	import flash.events.Event;
	
	import game.data.constant.name.CoreName;
	import game.data.constant.name.NotificationName;
	import game.data.constant.system.Path;
	import game.model.animation.AnimationModel;
	import game.view.char.CharacterView;
	
	import lib.gameEngine.common.data.Notification;
	import lib.gameEngine.core.Controller;
	import lib.utile.loader.BulkLoader;
	
	public class LoadCtr extends Controller{
		
		public function LoadCtr(){
			super(CoreName.LOAD);
		}
		
		override protected function registerNotify():void{  //注册通知
			this.addNotify(NotificationName.LOAD,onLoad);
		}
		
		private function onLoad(note:Notification):void{
			var loader:BulkLoader = new BulkLoader(CoreName.LOAD);
			
			//TODO  此处的路径应该从配置文件中读取
			loader.add(Path.SWF_PATH);
			loader.add(Path.XML_PATH);
			loader.addEventListener(Event.COMPLETE,onComplete);
			loader.start();
		}
		
		/**
		 * 一下整段代码都是用于测试，真正的业务还需要重新安排
		 * 
		 *  
		 * @param event
		 * 
		 */		
		private function onComplete(event:Event):void{
			if(!getView(CoreName.CHARACTER))registerView(new CharacterView());  //注册角色视图，其实是为了激活它的监听
			var animationModel:AnimationModel = getModel(CoreName.ANIMATION) as AnimationModel;
			if(!animationModel)animationModel = registerModel(new AnimationModel()) as AnimationModel;   //注册动画模型
			animationModel.parseXML();  //TODO 执行模型解析 
			animationModel.saveBm();
			
		}
	}
}